<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Gentelella Alela! | </title>

    <!-- Bootstrap -->
    <link href="/resources/gentelella/vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="/resources/gentelella/vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="/resources/gentelella/vendors/nprogress/nprogress.css" rel="stylesheet">
    <!-- iCheck -->
    <link href="/resources/gentelella/vendors/iCheck/skins/flat/green.css" rel="stylesheet">

    <!-- bootstrap-progressbar -->
    <link href="/resources/gentelella/vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css" rel="stylesheet">
    <!-- JQVMap -->
    <link href="/resources/gentelella/vendors/jqvmap/dist/jqvmap.min.css" rel="stylesheet"/>
    <!-- bootstrap-daterangepicker -->
    <link href="/resources/gentelella/vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="/resources/gentelella/css/custom.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/resources/datatables/dataTables.bootstrap.css?v=2">
    <link href="/resources/gentelella/vendors/datatables.net-bs/css/dataTables.bootstrap.min.css" rel="stylesheet">
    <link href="/resources/paginator/css/bootstrap-combined.min.css" rel="stylesheet">
    <link href="/resources/css/self.css" rel="stylesheet">
    <!-- table -->
    <script src="/resources/js/jquery-1.11.1.min.js"></script>
    <script src="/resources/datatables/jquery.dataTables.min.js"></script>
    <script src="/resources/datatables/dataTables.bootstrap.min.js"></script>
    <script src="/resources/paginator/js/bootstrap-paginator.js"></script>
    <script src="/resources/js/self.js?v=1"></script>
    <style type="text/css">
        .form-data{
            width: 150px !important;
        }
    </style>
</head>

<body>
<div class="col-md-12">
    <div class="box-body" style="padding-bottom:10px;">
        <div class="row form-inline" style="margin-left: 20px;">

            <div class="form-group">
                <label>名称:</label>
                <input type="text" class="form-control form-data" name="name"/>
                <input type="hidden" class="form-control form-data" name="type" value="staff"/>
            </div>

            <div class="form-group">
                <label>法人:</label>
                <input type="text" class="form-control form-data" name="chargePeople"/>
            </div>

            <button type="button"  onclick="searchData()" class="btn btn-primary">查询</button>


        </div>
        <div class="row form-inline" style="margin-left: 20px;margin-top:10px;">
            <button type="button" onclick="add()" class="btn btn-success">添加</button>
            <button type="button" onclick="edit()" class="btn btn-success">修改</button>
        </div>
    </div>
    <div class="x_panel">

        <table id="example" class="table table-bordered table-striped dataTable" cellspacing="0" width="100%">
            <thead>
            <tr>
                <th>选择</th>
                <th class="serial">序号</th>
                <th>运输公司名称</th>
                <th>法人</th>
                <th>电话</th>
                <th>地址</th>
                <th>描述</th>
            </tr>
            </thead>
        </table>
        <div id="example_page">
        </div>
    </div>
</div>


</body>
<script type="text/javascript">
    //列名称
    var columns = ["id","id","name","chargePeople","telephone","address","desc"];
    var createdCellFun = function (td, cellData, rowData, row, col) {
        /* $(td).css('color', 'red');*/

        switch (col){
            case 0:
                var html = "";
//                html += "<a href='javascript:void(0);' onclick='edit(\""+cellData+"\")' >修改</a>&nbsp;&nbsp;&nbsp;&nbsp;"
                html += "<input type='checkbox' value='"+cellData+"' name='select'/>";

                $(td).html(html);
                break;
            case 1:
                $(td).html( (row+1));
                break;
            case 2:
                var html = "";
                html += "<a href='javascript:void(0);' onclick='editIt(\""+rowData.id+"\")' >"+cellData+"</a>";

                $(td).html(html);
                break;
        }
    }


    $(function () {
        setTitle("基本信息>运输企业");
        buildPage("#example");
        var param = getParam();
        initDataTable("#example", "/company/transportCompany/list.do",param,columns,createdCellFun);
    });
    function getParam(){
        var param = getPageDataByClass("form-data");
        param['page']= 1;
        param['size']= 10;
        param['auditStatus'] = 'SUCCESS';
        return param;
    }
    function buildPage(element) {
        var param = getParam();
        //点击分页页面按钮
        var clickFun = function (e, originalEvent, type, page) {
            //构建查询参数
            param = getParam();
            param['size'] = 10;
            _page = page;
            param['page'] = page;
            initDataTable("#example", "/company/transportCompany/list.do", param, columns, createdCellFun);
        }
        $.ajax({
            url:"/company/transportCompany/count.do?_t=" + new Date().getTime(),
            data: param ,
            type:'post',
            dataType:"json",  //xml  html   script  jsonp
            success:function(result){
                initPage($("#example_page"),1,result.data,clickFun);
            }
        });
    }
    function searchData() {
        var param = getParam();
        initDataTable("#example", "/company/transportCompany/list.do", param, columns, createdCellFun);
        buildPage("#example");
    }
    function add() {
        goto("transportCompany_edit.html",{});


    }

    function edit() {
        var id = getOneSelectChecked();
        if(isNullOrUndefined(id)){
            alert("请选择要修改的数据,并且只能选择一条");
            return;
        }
        goto("transportCompany_edit.html",{"id":id});
    }
    function editIt(id) {
        goto("transportCompany_edit.html",{"id":id});
    }

    //通用 获取列表中选择的数据的id
    function getSelectChecked() {
        var ids = [];
        $("input[name='select']:checked").each(function(){
            ids.push($(this).prop("value"));
        });
        return ids;
    }
    function getOneSelectChecked() {
        var ids = getSelectChecked();
        if(ids.length == 0 || ids.length > 1) {
            return null;
        }
        return ids[0];
    }
    function checkAllSelect(node) {
        if($(node).prop("checked")) {
            $("input[name='select']").each(function(){
                $(this).prop("checked", true);
            });
        } else {
            $("input[name='select']").each(function(){
                $(this).prop("checked", false);
            });
        }
    }

</script>
</html>